--[[ 编码: WMS-28-16 名称: 盘点单-重置盘点单状态 作者:HAN 日期:2025-1-29 级别:项目 函数: ResetCountOrderState 功能: -- 根据对盘点单下面的盘点容器状态判断,判断是否可以关闭盘点单 -- 如果盘点单有盘点计划也判断一下盘点计划的状态是否可以设置为完成 更改记录: --]] wms_base = require ("wms_base") function ResetCountOrderState ( strLuaDEID ) local nRet, strRetInfo local count_order = {} nRet, count_order = m3.GetCurEditDataObj( strLuaDEID ) if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), "获取【盘点单】对象属性失败!"..count_order ) end -- 检查盘点单完成盘点数量 -- N_B_STATE = 3 已盘点 4 -- 回库 local strCondition = "S_COUNT_NO = '"..count_order.count_no.."' AND N_B_STATE >= 3" nRet, strRetInfo = mobox.getDataObjCount( strLuaDEID, "CP_Count_Container", strCondition ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "getDataObjCount失败!"..strRetInfo ) end local nCount = lua.StrToNumber( strRetInfo ) -- 更新【盘点单】的状态和已完成盘点数量 local strSetAttr = '' if ( count_order.num == nCount ) then -- N_B_STATE = 2 盘点单完成 strSetAttr = "N_B_STATE = 2, N_ACC_FINISH = "..nCount else strSetAttr = "N_ACC_FINISH = "..nCount end strCondition = "S_COUNT_NO = '"..count_order.count_no.."'" nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Count_Order", strCondition, strSetAttr ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【Count_Order】信息失败!"..strRetInfo ) end -- 如果有盘点计划更新盘点计划的累计盘点数量和计划状态 if ( count_order.cp_no == '' ) then return end -- 获取盘点计划已经完成盘点的盘点容器数量 -- N_B_STATE =3 已盘点 4 -- 回库 local strCondition = "S_CP_NO = '"..count_order.cp_no.."' AND N_B_STATE >= 3" nRet, strRetInfo = mobox.getDataObjCount( strLuaDEID, "CP_Count_Container", strCondition ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "getDataObjCount失败!"..strRetInfo ) end nCount = lua.StrToNumber( strRetInfo ) -- 更新【盘点计划】的状态和已完成盘点数量 local count_plan nRet, count_plan = m3.GetDataObjectByKey( strLuaDEID, "Count_Plan", "S_CP_NO", count_order.cp_no ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "GetDataObjectByKey失败"..count_order ) end -- 如果盘点计划的计划盘点容器数量 = 已经完成盘点的容器数量,盘点计划完成 if ( count_plan.plan_total == nCount ) then -- 3 盘点计划完成 strSetAttr = "N_B_STATE = 3, N_ACC_FINISH = "..nCount else strSetAttr = "N_ACC_FINISH = "..nCount end strCondition = "S_CP_NO = '"..count_order.cp_no.."'" nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Count_Plan", strCondition, strSetAttr ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "更新【Count_Plan】信息失败!"..strRetInfo ) end end